package com.itxzh.aop;

import org.aspectj.lang.ProceedingJoinPoint;

import java.time.Instant;

/**
 * 切面类，独立于业务逻辑外的功能
 */
public class TimeAspect {
    /**
     * 记录方法的执行时间
     * @param point
     */
    public void recorderTime(ProceedingJoinPoint point){
        long t1 = Instant.now().toEpochMilli();
        try {
            point.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        long t2 = Instant.now().toEpochMilli();
        System.out.println("执行时间：" + (t2 - t1) + "ms");
    }
}
